package com.enation.app.javashop.core.client.fallback.goods;

import com.enation.app.javashop.core.client.feignimpl.goods.GoodsQuantityClientFeignImpl;
import com.enation.app.javashop.core.handler.BaseFallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.enation.app.javashop.model.goods.vo.GoodsQuantityVO;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 *  商品库存client断路器 fallback factory
 * @author kingapex
 * @version 1.0
 * @data 2022/5/28 14:17
 **/
@Component
public class GoodsQuantityClientFallbackFactory  extends BaseFallbackFactory<GoodsQuantityClientFeignImpl> {
    @Override
    protected GoodsQuantityClientFeignImpl fallback() {
        return new GoodsQuantityClientFallback();
    }

    /**
     * @author fk
     * @version v2.0
     * @Description: 商品库存client断路器
     * @date 2018/9/29 9:31
     * @since v7.0.0
     */
    @Component
    public static class GoodsQuantityClientFallback implements GoodsQuantityClientFeignImpl {

        private final Logger logger = LoggerFactory.getLogger(getClass());

        @Override
        public boolean updateSkuQuantity(List<GoodsQuantityVO> goodsQuantityList) {

            logger.error("库存扣减失败");

            return false;
        }
    }
}
